<script type="text/javascript">
<!--
<?php 
	$all = count($dataProvider);
	$addresses = $images = $names = $urls = $prices = '';
	foreach ($dataProvider as $key => $object) :
		$address		= $object->country->name.', '.$object->city->name.', '.$object->street.' '.$object->house .'/'.$object->apartment;
		$image			= $object->mainImage ? 
			$this->material_image_src($object->mainImage->id, $object->mainImage->name, '205', 'images/'.$object->user_id.'/'.$object->id) : 
				$this->material_image_src(0, 'noimage.gif', '205', '');
		$url 			= Yii::app()->createUrl('cataloge/view', array('id'=>$object->id));
		$addresses 		.=  $key+1!=$all ? '"'.$address.'", ' : '"'.$address.'"';
		$images 		.=  $key+1!=$all ? '"'.$image.'", ' : '"'.$image.'"';
		$names 			.=  $key+1!=$all ? '"'.$object->name.'", ' : '"'.$object->name.'"';
		$urls 			.=  $key+1!=$all ? '"'.$url.'", ' : '"'.$url.'"';
		$prices 			.=  $key+1!=$all ? '"'.$object->price.'", ' : '"'.$object->price.'"';
	endforeach;
?>
window.addresses = [<?php echo $addresses;?>];
window.images = [<?php echo $images;?>];
window.names = [<?php echo $names;?>];
window.urls = [<?php echo $urls;?>];
window.prices = [<?php echo $prices;?>];
//-->
</script>
<div id="map_canvas" style="width:800px; height:500px; "></div>
<div class="cl list-object">
	<div class="content_holder fl">
		<div id="content">
			<div class="block_holder br5 greyBg search_panel">
				<div class="search_descr">
					<?php echo count($dataProvider);?> results found
					<?php echo Yii::app()->request->getParam('destination')!=NULL && Yii::app()->request->getParam('destination')!='Choose your destination...' ? ' in '.Yii::app()->request->getParam('destination') :' in all world';?>
					<?php echo Yii::app()->request->getParam('guest')!=NULL ? ', for '.Yii::app()->request->getParam('guest'):'';?>
					<?php echo Yii::app()->request->getParam('check_in')!=NULL ? ', from '.Yii::app()->request->getParam('check_in') : '';?>
					<?php echo Yii::app()->request->getParam('check_out')!=NULL ? ' until '.Yii::app()->request->getParam('check_out') : '';?>
				</div>
				<div class="buttons">
					<a href="#" class="listView"><?php echo Yii::t("main", "List")?></a>
					<a href="#" class="photoView"><?php echo Yii::t("main", "Photo")?></a>
				</div>
			</div>
			<div class="list big">
			<?php foreach ($dataProvider as $key => $object) : ?>
				<div class="object <?php echo ($key+1)%3==0 && $key!=0 ? 'third' : '';?>">
					<div class="object-price"><span><?php echo Yii::t("main", "from")?></span> <?php echo CHtml::encode($object->price); ?> €</div>
					<div class="object-img">
						<a href="<?php echo Yii::app()->createUrl('cataloge/view', array('id'=>$object->id)); ?>" title="<?php echo CHtml::encode($object->name); ?>">
							<?php if($object->mainImage){ ?>
								<?php echo $this->material_image($object->mainImage->id, $object->mainImage->name, '205', 'images/'.$object->user_id.'/'.$object->id); ?>
							<?php }else{ ?>
								<?php echo $this->material_image(0, 'noimage.gif', '205', ''); ?>
							<?php } ?>
						</a>
					</div>
					<h3 class="object-name">
						<a href="<?php echo Yii::app()->createUrl('cataloge/view', array('id'=>$object->id)); ?>" title="<?php echo CHtml::encode($object->name); ?>" class=""><?php echo CHtml::encode($object->name); ?></a>
					</h3>
					<?php if(isset($object->roomType)):?>
					<p><?php echo CHtml::encode($object->roomType->name); ?></p>
					<p class="descr"><?php echo CHtml::encode($object->description); ?></p>
					<div class="author">
						<a href="<?php echo Yii::app()->createUrl('users/view', array('id'=>$object->user->id));?>" class="photo">
							<?php echo $this->material_image($object->user->id, $object->user->avatar, '38', 'images/' . $object->user->id); ?>
						</a>
						<p><?php echo $object->user->full_name; ?></p>
						<p><span>10 Review</span></p>
					</div>
					<?php endif;?>
					<?php $address = $object->country->name.', '.$object->city->name.', '.$object->street.' '.$object->house .'/'.$object->apartment;?>
					<a href="#" class="onmap showMap" title="<?php echo $address?>"><?php echo $address?></a>
				</div>
			<?php endforeach; ?>
			</div>
			<div class="clear"></div>
		</div>
	</div>
	<div id="right" class="br5 catalog-filter">
		<form>
			<div class="row cl">
				<h3><?php echo Yii::t('main','Place') ?></h3>
				<div class="filter_content">
					<div class="inp_col  fl">
						<label>Country</label>
						<div class="select br3">
							<?php $country = isset($_GET['country']) ? $_GET['country'] : null ; ?>
							<?php
								echo CHtml::dropDownList(
									'country', 
									$country,
									CSelect::items('Country'),
									array( 'empty' => (Yii::t('main', 'Select a country')), 'id'=>'Object_country_id')
								);
							?>
						</div>
					</div>
				</div>
			</div>
			<div class="row cl">
				<div class="filter_content">
					<div class="inp_col  fl">
						<label>City</label>
						<div class="select br3">
							<?php $city = isset($_GET['city']) ? $_GET['city'] : null ; ?>
							<?php 
							// print_r($city);
								echo CHtml::dropDownList(
									'city',$city, 
									$cityList,
									array('empty' => (Yii::t('main', 'Select a country')),'id'=>'Object_city_id')
								); 
							?>
						</div>
					</div>
				</div>
			</div>
			<div class="row cl">
				<h3><?php echo Yii::t('main','Date') ?></h3>
				<div class="filter_content">
					<div class="inp_col fl">
						<?php echo CHtml::label('Check_in','check_in'); ?>
						<div class="inp_text">
							<?php $check_in = (isset($_GET['check_in'])) ? $_GET['check_in'] : '' ; ?>
							<?php echo CHtml::textField('check_in',$check_in, array('class'=>'br3 bsi15 datePicker')); ?>
						</div>
					</div>
					<div class="inp_col fl">
						<?php echo CHtml::label('Check_out','check_out'); ?>
						<div class="inp_text">
							<?php $check_out = (isset($_GET['check_out'])) ? $_GET['check_out'] : '' ; ?>
							<?php echo CHtml::textField('check_out',$check_out, array('class'=>'br3 bsi15 datePicker')); ?>
						</div>
					</div>
					<div class="inp_col sel fl">
						<label>Guests</label>
						<div class="select br3">
							<?php
								echo CHtml::dropDownList('guest', '',
									array(
										'1'=>1,
										'2'=>2,
										'3'=>3,
										'4'=>4,
										'5'=>5,
										'6'=>6,
										'7'=>7,
										'8'=>8,
										'9'=>9,
										'10'=>10,
									)
								);
							?>
						</div>
					</div>
				</div>
			</div>
			<div class="row cl">
				<h3><?php echo Yii::t("main", "Price")?></h3>
				<div class="filter_content">
					<div class="inp_col fl">
						<?php echo CHtml::label('From','from_price'); ?>
						<div class="inp_text">
							<?php $from_price = (isset($_GET['from_price'])) ? $_GET['from_price'] : '' ; ?>
							<?php echo CHtml::textField('from_price', $from_price, array('class'=>'br3 bsi15')); ?>

						</div>
					</div>
					<div class="inp_col fl">
						<?php echo CHtml::label('Until','until_price'); ?>
						<div class="inp_text">
							<?php $until_price = (isset($_GET['until_price'])) ? $_GET['until_price'] : '' ; ?>
							<?php echo CHtml::textField('until_price', $until_price, array('integerOnly'=>true, 'class'=>'br3 bsi15')); ?>
						</div>
					</div>
				</div>
			</div>
			<div class="row cl">
				<h3><?php echo Yii::t("main", "Room Type")?></h3>
				<div class="filter_content">
				<?php foreach ($roomType as $key => $object) : ?>
					<div class="radio_box cl">
						<?php $check = (isset($_GET['roomType'][$object->id])) ? true : false; ?>
						<?php echo CHtml::checkBox('roomType['.$object->id.']', $check, array('class'=>'styled')); ?>
						<?php echo CHtml::label($object->name, 'roomType_'.$object->id); ?>
					</div>
				<?php endforeach; ?>
				</div>
			</div>
			<div class="row cl">
				<h3><?php echo Yii::t("main", "Continent")?></h3>
				<div class="filter_content">
					<div class="radio_box cl">
						<?php $check = (isset($_GET['continent']['1'])) ? "checked" : "" ; ?>
						<input type="checkbox" name="continent[1]" id="continent_1" class="styled" <?php echo $check; ?> />
						<label for="continent_1"><?php echo Yii::t('main','Classic Europe');?></label>
					</div>
					<div class="radio_box cl">
						<?php $check = (isset($_GET['continent']['2'])) ? "checked" : "" ; ?>
						<input type="checkbox" name="continent[2]" id="continent_2" class="styled" <?php echo $check; ?> />
						<label for="continent_2"><?php echo Yii::t('main','Young America');?></label>
					</div>

					<div class="radio_box cl">
						<?php $check = (isset($_GET['continent']['3'])) ? "checked" : "" ; ?>
						<input type="checkbox" name="continent[3]" id="continent_3" class="styled" <?php echo $check; ?> />
						<label for="continent_3"><?php echo Yii::t('main','Hot Asia');?></label>
					</div>
					<div class="radio_box cl">
						<?php $check = (isset($_GET['continent']['4'])) ? "checked" : "" ; ?>
						<input type="checkbox" name="continent[4]" id="continent_4" class="styled" <?php echo $check; ?> />
						<label for="continent_4"><?php echo Yii::t('main','Wild Africa');?></label>
					</div>
					<div class="radio_box cl">
						<?php $check = (isset($_GET['continent']['5'])) ? "checked" : "" ; ?>
						<input type="checkbox" name="continent[5]" id="continent_5" class="styled" <?php echo $check; ?> />
						<label for="continent_5"><?php echo Yii::t('main','Exotic Australia & New Zealand');?></label>
					</div>
				</div>
			</div>
	
			
			<div class="submit cl">
				<?php echo CHtml::submitButton(Yii::t("main", "Search"), array('class'=>'btn blue br3')); ?>
			</div>
		</form>
	</div>
</div>
